package ncov.service.impl;

import ncov.dao.GradeDao;
import ncov.model.Grade;
import ncov.model.Staff;
import ncov.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author WuChangJian
 * @date 2020/6/8 17:00
 */
@Service
@Transactional
public class GradeServiceImpl implements GradeService {

    @Autowired
    private GradeDao gradeDao;

    @Override
    public Grade getGrade(Integer gradeId) {
        if (gradeId != null) {
            return gradeDao.queryById(gradeId);
        }
        return null;
    }

    @Override
    public List<Grade> getGradesByStaffId(Integer staffId) {
        if (staffId != null) {
            Grade grade = new Grade();
            Staff staff = new Staff();
            staff.setStaffId(staffId);
            grade.setStaff(staff);
            return gradeDao.queryAll(grade);
        }
        return null;
    }
}
